package test.fastjson;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.luotao.devp.base.test.TesterConcurrent;
import com.luotao.devp.base.utils.StringUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * Created by IntelliJ IDEA.
 * User: luotao
 * Date: 12-5-29
 * Time: 15:13
 */
public class Map_JsonStr_Str_JsonObj implements TesterConcurrent.ITestable {
     public static final String KEY1 = "key1";

    public static final String KEY2 = "key2";

    public static final String KEY3 = "key3";

    public static final String KEY4 = "key4";

    public static final String KEY5 = "key5";

    public static final String KEY6 = "key6";

    public static final String KEY7 = "key7";

    public static final String KEY8 = "key8";

    public static final String KEY9 = "key9";

    public static final String KEY10 = "key10";

    public static final String KEY11 = "key11";

    public static final String KEY12 = "key12";

    public static final String KEY13 = "key13";

    public static final String KEY14 = "key14";

    public static final String KEY15 = "key15";

    public static final String KEY16 = "key16";
    @Override
    public void execute(long index, long threadid, int loop_index) throws Exception {
//                Request req = new Request();
//                req.setFlowid(StringUtils.fillZero(index,24));
//                req.setCustomerId(StringUtils.fillZero(index,20));
//                req.setSendType((byte)loop_index);
//                req.setTradeMoney((int)threadid);
//
//                req.setCreatetime((int) System.currentTimeMillis());
//                req.setConfirmTime((int) System.currentTimeMillis());
//                req.setMappedFlowid(StringUtils.fillZero(String.valueOf(threadid), 24));
//                req.setGameCode((int) loop_index);
//
//                req.setChannelType((byte) (loop_index * 4));
//                req.setMobileOSType("iphone" + index);
//                req.setMultiple((short) new Random().nextInt(99));
//                req.setPeroid("peroid" + index);
//
//                req.setAutoAwardTime((int) System.currentTimeMillis());
//                req.setEndAwardTime((int) System.currentTimeMillis());
//                req.setAutoBingoMoney((int) index);
//                req.setTicketConent(StringUtils.fillZero(String.valueOf(threadid), 128).getBytes());
//
//                String str = JSON.toJSONString(req);
//
//                JSONObject ress = JSON.parseObject(str);
//                ress.get(KEY1);
        Map map = new HashMap();
        map.put(KEY1, StringUtils.fillZero(index, 24));
        map.put(KEY2, StringUtils.fillZero(index, 20));
        map.put(KEY3, (byte) loop_index);
        map.put(KEY4, (int) threadid);

        map.put(KEY5, (int) System.currentTimeMillis());
        map.put(KEY6, (int) System.currentTimeMillis());
        map.put(KEY7, StringUtils.fillZero(String.valueOf(threadid), 24));
        map.put(KEY8, (int) loop_index);

        map.put(KEY9, (byte) loop_index * 4);
        map.put(KEY10, "iphone" + index);
        map.put(KEY11, (short) new Random().nextInt(99));
        map.put(KEY12, "peroid" + index);

        map.put(KEY13, (int) System.currentTimeMillis());
        map.put(KEY14, (int) System.currentTimeMillis());
        map.put(KEY15, (int) index);
        map.put(KEY16, StringUtils.fillZero(String.valueOf(threadid), 128));

        String str = JSON.toJSONString(map);
        JSONObject ress = JSON.parseObject(str);
        ress.get(KEY1);

//                Map result_map = JSON.parseObject(str,Map.class);
//                result_map.get(KEY16);
//                System.out.println("result_map = " + result_map);
//               System.out.println("str = " + str);
    }
}
